import 'package:eh_mobile/common/utils/toast/bnw_toast.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class DeviceNameController extends GetxController {
  DeviceNameController();

//输入框控制器，一般用于获取文本、修改文本等
  final TextEditingController inputController = TextEditingController();
  //焦点节点，一般用于自动获取焦点，取消焦点以便隐藏键盘等
  final FocusNode inputFocusNode = FocusNode();
  bool hiddenClearButton = false;
  // 键盘是否已经弹出
  bool keyboardShow = false;

  _initData() {
    update(["device_name"]);
  }

  // 提交设备名称
  void submitClick() {
    if (inputController.text.isEmpty) {
      BnwToast.showView(Get.context!,infoStr:'设备名称不能为空');
      return;
    }
    inputFocusNode.unfocus();

    Get.back(result: inputController.text);
  }

  @override
  void onInit() {
    String text = Get.arguments;
    inputController.text = text;
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    _initData();
  }

  @override
  void onClose() {
    inputController.dispose();
    inputFocusNode.dispose();
    super.onClose();
  }
}
